﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Configuration.Provider;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.UI;
using Formsy.Common;

namespace Formsy.Providers.CustomField
{
    public abstract class CustomFieldProvider : ProviderBase
    {
        /// <summary>
        /// Adds a new HtmlGenericControl to the fieldSet.
        /// The return value must be the containing div
        /// </summary>
        /// <param name="field">An XElement containing the field definition in the xml file.</param>
        /// <param name="div">The current containing div.</param>
        /// <param name="fieldSet">The current containing FieldSet</param>
        /// <param name="formFields">Formsy's FormField collection so validation and value retrieval can occur.</param>
        /// <returns>The containing div.</returns>
        public abstract HtmlGenericControl CreateCustomField(XElement field, HtmlGenericControl div, HtmlGenericControl fieldSet, List<FormField> formFields);

    }


    public class CustomFieldProviderCollection : ProviderCollection
    {
        // Return an instance of DataProvider
        // for a specified provider name
        new public CustomFieldProvider this[string name]
        {
            get { return (CustomFieldProvider)base[name]; }
        }
    }
}

